package apiday05home;

import java.io.File;
import java.io.FileFilter;

public class Test06 {
    public static void main(String[] args) {
        File dir = new File(".");
        if(dir.isDirectory()){
            FileFilter filter = new FileFilter() {
                public boolean accept(File file) {
                    String name = file.getName();
                    return name.endsWith("s");
                }
            };
            //返回目录中所有满足过滤器要求的子项
            File[] subs = dir.listFiles(filter);
            for(File sub : subs){
                System.out.println(sub.getName());
            }
        }
        /*
        if(dir.isDirectory()){
            File[] subs = dir.listFiles(file -> file.getName().endsWith(".txt"));
            for(File sub : subs){
                System.out.println(sub.getName());
            }
        }
         */
    }
}
